

let app = new Vue({
    el:"#app",
    data:{
        activity:[],
        now:0,
        deadline:0,
        last_time:0,
    },
    computed:{


    },
    mounted:function () {
    let id =get_query_string('id');

    axios.get(host+"/activities/"+ id +"/")
                .then(response =>{
                    this.activity = response.data;


                    // this.now = new Date(response.headers.date).getTime();
                    this.now =  Date.parse(new Date());
                    console.log(this.now)
                    this.deadline = new Date(this.activity.deadline).getTime();
                    console.log(this.deadline)
                    // setInterval(function () {
                    //     this.now += 1000;
                    //     this.last_time = this.now - this.deadline
                    //
                    // },1000);

                    setInterval(
                        ()=>{
                            this.now += 1000;
                            this.last_time =  this.deadline - this.now

                        }


                        ,1000)
                })
                .catch(error =>{})

    },
                method:{

                },
                filters:{
                    countdown2dhms:function(value_ms){
                        // let seconds = value_ms/1000;
                        // let day = Math.floor(seconds/1000/(60*60*24));
                        // let hour = seconds%(60*60*24);
                        // let minute = seconds%(60*60);
                        // let second = seconds%(60);

                      let  d = Math.floor(value_ms/1000/60/60/24);
				        let h = Math.floor(value_ms/1000/60/60%24);
				       let m = Math.floor(value_ms/1000/60%60);
				        let s = Math.floor(value_ms/1000%60);
                        return d+ "天"+h+"时"+m+"分"+s+"秒"
                    }
                }

})





